from flask import Flask, session

app = Flask(__name__)
# 方式1
# app.secret_key='aaa'
#方式2
app.config['SECRET_KEY']='AAA'

@app.route('/set_session')
def set_session():
    # 设置session
    session['name']='laowang'
    return 'hello world'

@app.route('/get_session')
def get_session():
    #获取session
    name = session.get('name')
    return 'get_session:{}'.format(name)

if __name__ == '__main__':
    app.run(debug=True)